package com.banciyuan.bcywebview.base.view.other;

import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Paint;
import android.graphics.Path;
import android.util.AttributeSet;
import android.view.View;

import com.banciyuan.bcywebview.R;

/**
 * Created by hy on 2016/3/29.
 */
public class TriangleShapeView extends View {
    private Path path;
    private Paint p;

    public TriangleShapeView(Context context) {
        super(context);
        init();
    }

    public TriangleShapeView(Context context, AttributeSet attrs, int defStyle) {
        super(context, attrs, defStyle);
        init();
    }


    public TriangleShapeView(Context context, AttributeSet attrs) {
        super(context, attrs);
        init();
    }

    private void init() {
        path = new Path();
        p = new Paint();
    }

    protected void onDraw(Canvas canvas) {
        super.onDraw(canvas);
        int w = getWidth();
        path.moveTo(w, 0);
        path.lineTo(w, w);
        path.lineTo(0, w);
        path.lineTo(w, 0);
        path.close();
        p.setColor(getResources().getColor(R.color.content_background));

        canvas.drawPath(path, p);
    }
}
